package com.example.common.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.time.Duration;

@Data
@Component
@ConfigurationProperties(prefix = "spring.redis")
public class RedisProperties {
    private String host;
    private int port;
    private String password;
    private int database;
    private Duration timeout;
    private Lettuce lettuce;

    @Data
    public static class Lettuce {
        private Pool pool;
        private Duration shutdownTimeout;
        private Cluster cluster;
        private Netty netty;
    }

    @Data
    public static class Pool {
        private int maxActiveSessions;  // 最大连接数
        private int maxIdle;            // 最大空闲连接数
        private int minIdle;            // 最小空闲连接数
        private Duration maxWait;       // 获取连接最大等待时间
    }

    @Data
    public static class Cluster {
        private Refresh refresh;
    }

    @Data
    public static class Refresh {
        private boolean adaptive;       // 自适应刷新
        private Duration period;        // 刷新周期
    }

    @Data
    public static class Netty {
        private int ioThreads;          // IO线程数
        private int computationThreads; // 计算线程数
    }
}
